 export default function (app) {

  app.directive('integer', integer);

  function integer () {
    'ngInject';

    let INTEGER_REGEXP = /^\-?\d+$/;
    return {
      restrict: 'A',
      link: linkFn,
      require: 'ngModel'
    };

    function linkFn (scope, elem, attrs, ctrl) {
      ctrl.$validators.integer = function(modelValue, viewValue) {
      	console.log('modelValue:' + modelValue);
      	console.log('viewValue:' + viewValue);
        if (ctrl.$isEmpty(modelValue)) {
          // consider empty models to be valid
          return true;
        }

        if (INTEGER_REGEXP.test(viewValue)) {
          // it is valid
          return true;
        }

        // it is invalid
        return false;
     };
    }
  }
}